import request from '@/utils/request'

// 获取图书数据
export function getBookinfo(size, offset) {
  return request({
    url: '/bookinfo',
    method: 'get',
    params: { size, offset }
  })
}

// 添加图书
export function addBook(data) {
  return request({
    url: '/addbook',
    method: 'put',
    data: {
      book_author: data.author,
      book_type: data.bookType,
      book_name: data.bookName,
      book_press: data.bookPress,
      book_stock: data.bookStock,
      book_state: data.bookState
    }
  })
}

// 修改图书信息
export function mdBook(data) {
  return request({
    url: '/mdbook',
    method: 'post',
    data
  })
}

// 删除图书信息
export function dlBook(data) {
  return request({
    url: '/dlbook',
    method: 'post',
    data
  })
}

// 借书或预约
export function boBook(data) {
  return request({
    url: '/bobook',
    method: 'post',
    data
  })
}

// 获取个人图书数据
export function userBorrowBook(data) {
  return request({
    url: '/borbook',
    method: 'get',
    params: { ...data }
  })
}

// 取消图书的预约/取消借书
export function cancalBook(data) {
  return request({
    url: '/cancal',
    method: 'post',
    data
  })
}
